<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="${ctx}/js/ext-3.3.0/resources/css/ext-all.css"/>
<link href="${ctx}/css/css51.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-base.js"></script>
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-all.js"></script>
<script type="text/javascript" src="${ctx}/js/ext-3.3.0/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="${ctx}/js/ajaxfileupload.js"></script>
<title>后台用户管理</title>
<script type="text/javascript">
	String.prototype.replaceAll = function(s1,s2) {
	   	return this.replace(new RegExp(s1,"gm"),s2);
	}
	//批量删除
	function listDelete(id){
		Ext.Msg.confirm('信息','确定要删除?',function(btn){
			if(btn == "yes"){
				$.ajax({
	    			url : "${ctx}/crmmerchant/ajax/updateByIds",
	 				data:{
	    				ids:id
	 				},
	 				type:"post",
	 				success:function(data){
	 					if(data == "1"){
	 						alert("操作成功");
	 						Ext.getCmp("grid2").getStore().removeAll();
		      				Ext.getCmp("grid2").getStore().load("${ctx}/crmuserlog/ajax/list");
	 						//document.location.reload();
	 					}else{
	 						alert("操作失败");
	 					}
	 				}
	 			});
			}
 		})
	}
	var list;
	var win;
	var saveCommand;
	Ext.onReady(function(){
    	var store = new Ext.data.Store({
	       	proxy:new Ext.data.HttpProxy({
	       		url: '${ctx}/crmuserlog/ajax/list'
	       	}),
	       	//读取数据源用json方法(三种方法1.读取json用JsonReader,2读取数组使用ArrayReader3.读取XML用XmlReader)
	       	reader:new Ext.data.JsonReader({
				root:"root",
	           	//从数据库中读取的总记录数
	           	totalProperty: 'count',
	           	fields:[
	                    'id','userId','userName','operateTime','rightText','operateContent'
	                   ]
			})
		});
	
  		var bbar= new Ext.PagingToolbar({
	        pageSize: 25,
	        store: store,
	        loadMask: this.LoadMask,
	        displayInfo: true,
	        displayMsg: '当前为第[{0}]</span>条至第[{1}]条数据，共[{2}]条数据',
	        emptyMsg: "没有数据"
	    });
  		var sm = new Ext.grid.CheckboxSelectionModel();//复选框
		var cm = new Ext.grid.ColumnModel([
          	{header: "id", width: 20, sortable: true, dataIndex: 'id'},
          	{header: "用户id", width: 120, sortable: true, dataIndex: 'userId'},
          	{header: "用户名", width: 120, sortable: true, dataIndex: 'userName'},
          	{header: "操作时间", width: 120, sortable: true, dataIndex: 'operateTime'},
          	{header: "操作内容", width: 120, sortable: true, dataIndex: 'operateContent'}
    	]);
		var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"加载数据中,请等待......",store:store,removeMask :true});
	    var grid= new Ext.grid.GridPanel({
	    	id:'grid2',
	    	layout : 'fit',
	    	//自动适应宽高
	        //autoWidth:true,
	    	//autoHeight : true,
	        width:document.body.clientWidth,
	        height:document.documentElement.clientHeight,
	    	//指定div的ID
	    	//el:'pageGrid',
	    	maskText : '正在加载中...',
	     	getLoadMask : function(){
	         	if(this.LoadMask){
	          		return this.LoadMask;
	         	}else{
	          		this.LoadMask = new Ext.LoadMask(Ext.getBody(),{msg:this.maskText,removeMask : true});
	          		return this.LoadMask;
	         	}
	        },
	        setMaskText : function(msg){
	        	this.maskText = msg;
	        	this.getLoadMask().msg = this.maskText;
	        },
     		store:store,
     		tbar : [],
         	cm:cm,
         	sm:sm,
         	//sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
         	viewConfig:{
          		forceFit: true
         	},  
         	frame:true,    
         	// 自动出现 expand/collapse toggle button, 上下收展的按纽   
         	titleCollapse: true, 
         	//collapsible: true,点击title也可以收展    
         	hideCollapseTool: true, 
         	//title:'用户投诉', // 表格标题    
         	header: false, 
         	// 不创建标题栏    
         	headerAsText: true, 
         	// 如果有标题栏, 隐藏标题栏    
         	iconCls:'icon-grid',  
         	//显示等待数据加载（loading）图标
         	loadMask: this.LoadMask,
         	//表格的工具栏    
         	/*tools:[ 
          	// 与title同一栏的按纽          
          	//{id:"save"},
          	{id:"help", 
          	handler:function(){
	          	Ext.Msg.alert('help','有问题？');}}, 
          	{id:"close",handler:function(){
     		Ext.Msg.alert('help','你想死啊');}}
           	// 按纽取值如下, close,minimize ,maximize ,restore ,gear ,pin ,unpin          
           	// toggle, down ,refresh ,minus ,plus ,help ,search ,save ,right ,left ,up  
          	],*/
          	//自带分页工具条
          	bbar: bbar
		});
		store.on('beforeload',function( store , options ){
			store.baseParams = {
          		//searchDealWithStatus:Ext.get("searchDealWithStatus").dom.value
          		//Ext.get('searchSourceCity').getValue()
        		//keyword : Ext.getCmp('keyword').getValue();
         		//limit:grid.pagingConfig.pageSize;
          	};
       	 });
   		 grid.render("pageGrid");
    	 store.load({
    		 params:{start:0,limit:25},
    		 callback:function(data,options,success){
	        	for (var i = 0; i < store.getCount(); i++){
					 //alert(data[i].get('dfName'));
    			 }  
	        	
			}}
    	 );
    });
</script>
</head>

<body>
	
	<div id="pageGrid"></div>
</body>
</html>
